﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    public class Test
    {

        public static void Main(String[] args)
        {
            int X = 6;

            
        }

        

        public static int Solve(int X, int N, bool printPath, ArrayList operations, int curX, int operand)
        {
            if (operations.Count == N - 1)
            {
                if (curX == X)
                {
                    if (printPath)
                    {
                        Console.Write("CORRECT PATH: ");
                        foreach (int elem in operations)
                        {
                            Console.Write(elem + " ");
                        }
                        Console.WriteLine();
                    }
                    return 1;
                }

                return 0;
            }

            int res = 0;

            int nextOperand = operand + 1;

            operations.Add(1);
            res = res + Solve(X, N, printPath, operations, curX + operand, nextOperand); // plus
            operations.RemoveAt(operations.Count - 1); // remove last

            operations.Add(2);
            res = res + Solve(X, N, printPath, operations, curX - operand, nextOperand); // minus
            operations.RemoveAt(operations.Count - 1); // remove last

            operations.Add(3);
            res = res + Solve(X, N, printPath, operations, curX * operand, nextOperand); // multiple
            operations.RemoveAt(operations.Count - 1); // remove last

            operations.Add(4);
            res = res + Solve(X, N, printPath, operations, curX / operand, nextOperand); // delete
            operations.RemoveAt(operations.Count - 1); // remove last

            return res;
        }
    }
}